import { ApiProperty } from "@nestjs/swagger";
import { BaseEntity, PaginatedResult } from "src/common/entities/entities";
import { JumpType, Status } from "src/dictionaries/index.enum";
import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
import { MovieEntity } from "../../movies/entities/movie.entity";

@Entity('banner')
export class BannerEntity extends BaseEntity {
    /** 轮播图片 */
    @ApiProperty({ example: 'img', description: '轮播图片' })
    @Column({
        type: 'text',
        comment: 'img',
        nullable: true
    })
    img: string;
    /** 是否启用 */
    @ApiProperty({
        enum: Status,
        example: Status.ENABLED,
        description: '是否启用',
    })
    @Column({
        type: 'enum',
        enum: Status,
        default: Status.ENABLED,
    })
    status: Status;

    /** 排序 */
    @ApiProperty({ example: 'sort', description: '排序' })
    @Column({
        type: 'tinyint',
        comment: '排序',
        default: 0,
    })
    sort: number;

    /** 跳转类型 */
    @ApiProperty({
        enum: JumpType,
        example: JumpType.none,
        description: '跳转类型',
    })
    @Column({
        type: 'enum',
        enum: JumpType,
        default: JumpType.none,
    })
    jumpType: JumpType;

    /** 跳转链接 */
    @ApiProperty({ example: 'url', description: '跳转链接' })
    @Column({
        type: 'varchar',
        comment: '跳转链接',
        nullable: true
    })
    url: string;

    /** 备注 */
    @ApiProperty({ example: 'remarks', description: '备注' })
    @Column({
        type: 'varchar',
        comment: '备注',
        nullable: true
    })
    remarks: string;

    /** 语言 */
    @ApiProperty({ example: 'lang', description: '语言' })
    @Column({
        type: 'varchar',
        comment: '语言',
        length: 50,
    })
    lang: string;

    /** 电影Id */
    @ApiProperty({ example: 'moviesId', description: '电影Id' })
    @Column({
        type: 'int',
        comment: '电影Id',
        nullable: true,
    })
    moviesId: number;
    /** 关联的电影实体 */
    @ApiProperty({ example: MovieEntity, description: '电影' })
    @ManyToOne(() => MovieEntity, (movies) => movies.id)
    @JoinColumn({ name: 'moviesId' })
    movies: MovieEntity;
}
export class BannerResult extends PaginatedResult {
    @ApiProperty({ example: 'data', description: 'data' })
    data: BannerEntity;
}